{include file="public/header"/}
<link rel="stylesheet" href="{__ADMIN_PATH}/pcf/template.css?v={$version}" media="all">
<script src="{__PUBLIC_PATH}/common/js/jquery.min.js?v={$version}"></script>
<script src="{__PUBLIC_PATH}/admin/pcf/global.js?v={$version}"></script>
</head>
<body>
<style type="text/css" media="screen">
.pcf_template .cmdlist-container{background:#fff;border:5px solid #eee;padding:4px;}
.pcf_template .cmdlist-text .info{font-weight:bold;height:34px;line-height:34px;color:#333;}
.pcf_template .cmdlist-text{padding:4px;}
.pcf_template .cmdlist-text span{color:#666;display:block;margin:4px 10px;}
.pcf_template img{width:100%;height:200px;}
.pcf_template .layui-form-switch{margin-top:0;} 
#pcfbtn{cursor:pointer;}
</style>
<div class="layui-fluid layadmin-maillist-fluid pcf_template">
<div class="layui-card">
<blockquote class="layui-elem-quote">
    分离式模板：请同时建立pc和mobile两个文件夹<br>
    响应式模板：只需要建立pc一个文件夹<br>
    而且文件夹名称必须是pc和mobile，其它名称不能识别！<br>
</blockquote>
<div class="head-oper">
<div class="fl"></div>
<div class="fr"></div>
<div class="layui-card-body">
  <div class="layui-row layui-col-space15">
    {volist name='$list' id='vo'}
    <div class="layui-col-md2 layui-col-sm4">
      <div class="cmdlist-container"> 
        <a data-type="{:url('/channel.filemanager/lists', array('activepath'=>replace_path($vo.filepath)))}" id="pcfbtn">
        <img width="100%" height="auto" src="{$vo.preview}?t={php}echo time();{/php}"></a>
        <div class="cmdlist-text"> 
          <span class="info"><a data-type="{:url('/channel.filemanager/lists', array('activepath'=>replace_path($vo.filepath)))}" id="pcfbtn">
          {$vo.title} <b style="color:#3366cc;font-size:12px;font-weight:normal">[管理]</b></a></span> 
          <span>
          <div class="layui-form">
            <label>状态：</label>
            <input type="checkbox" name="is_default"  value="{$vo.is_default}" lay-skin="switch" lay-filter="is_default" lay-text="开启|关闭" data-theme="{$vo.filename}" {if $vo.is_default == 1}checked{/if}>
          </div>
          </span>
          <span style="height:48px;line-height:48px;">风格名称：{$vo.config.mbname}</span> 
        </div>
      </div>
    </div>
    {/volist}
  </div>
</div>
</div>
</div>
</div>
{include file="public/footer"/}
<script>
    layui.use('form', function(){
      var $ = layui.$,
        layer = layui.layer,
        form = layui.form;
        form.render();
        $(document).on("click",".pcf_template #pcfbtn",function(){
          var tplurl = $(this).data('type');
          var edittplpass = "{$edittplpass}";
          if(edittplpass){
             window.location.href = tplurl;
          }else{
              parent.layer.prompt({title:'<font color="red">输入密码</font>',formType: 1},
              function(val, index){
                $.ajax({
                    url: "{:url('/channel.filemanager/edittpl')}",
                    type: 'POST',
                    dataType: 'JSON',
                    data: {pass:val},
                    success: function(res){
                        if (res.status) {
                            window.location.href = tplurl;
                        } else {
                            parent.layer.msg(res.msg, {icon:2, time:1000});
                            return false;
                        }
                    },
                    error: function(e){
                        parent.layer.msg("未知错误，操作中断！", {icon:2, time:1000});
                        return false;
                    }
                });
                parent.layer.close(index);
              }
            );              
          }
        });
        //开启关闭
        form.on('switch(is_default)', function(data){
            var theme = $(this).data('theme');
            if (data.elem.checked){
                $(this).val(1);
            }else{
                $(this).val(0);
            }
            layer.load(2);
            $.ajax({
                type : 'post',
                url : "{:url('/channel.filemanager/ajax_set_theme')}",
                data : {theme:theme},
                dataType : 'json',
                success : function(res){
                    layer.closeAll('loading');
                    if(res.status){
                        layer.msg(res.msg,{time:500},function(){
                            window.location.reload();
                        });
                    }else{
                        layer.msg(res.msg, {icon: 2, time: 1000});
                    }
                },
                error: function(e){
                    layer.closeAll('loading');
                    layer.msg("未知错误，操作中断！", {icon: 2, time: 1000});
                }
            });
            return false;
        });
    });
</script>
</body>
</html>